<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ERN Debugging</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
	function loadError(errorNum) {
		location.href = '<?= $_SERVER['PHP_SELF'] ?>?ern=' + errorNum;
	}
</script>
</head>
<body>
<div style="margin:20px; font-size:14px; background-color:#CECEFF; border: 1px solid #000080; padding: 10px; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-weight:none;"><strong>Error Reference Number: </strong><input type="text" id="ERN" style="width: 40px;"><input type="button" onClick="loadError(document.getElementById('ERN').value)" value="Load"></div>	
<table style="margin:20px; font-size:14px; background-color:#CECEFF; border: 1px solid #000080; padding: 10px; text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif; font-weight:none;">
	<tr>
		<th>ERN</th>
		<th>Triggered By</th>
		<th>Time Triggered</th>
		<th>Description</th>
	</tr>
</table>
<?php
	require_once("setup.inc.php");
	if(isset($_REQUEST['ern'])) {
		$error_id = hexdec($_REQUEST['ern']);
		$sql = "SELECT * FROM `errors` WHERE `error_id` = " . $error_id;
		$result = mysql_query($sql);
		$data = mysql_fetch_assoc($result);
		$errorLevel = array("","ERROR","WARNING","","DEBUG","INFO");
		$systemError = array("NO","YES");
		?>
	<div style="margin:20px; font-size:12px; background-color:#FFFFFF; border: 1px solid #000000; padding: 10px; text-align:left; font-family:Verdana, Arial, Helvetica, sans-serif; font-weight:none;">
		<div style="font-weight:bold; ">Error Reference Number: <?= dechex($data['error_id']) ?> (<?= $data['error_id']?>)</div>
		<div style="font-weight:bold; ">Error Level: <?= $errorLevel[$data['error_type']] ?></div>
		<div style="font-weight:bold; ">System Error: <?= $systemError[$data['system_error']] ?></div>
		<div style="font-weight:bold; ">Description: <?= $data['description'] ?></div>
		<div style="font-weight:bold; ">Debug Data:
			<div style="font-family:'Courier New', Courier, mono "><?= str_replace("\n","<br>\n",$data['debug_info'])?></div></div>
	</div>
	<?php
	}
	?>
</body>
</html>
